#pragma once

class CByteCall
{
public:
    typedef HANDLE (*_Func)();

    HANDLE Call(DWORD dwStart, DWORD dwEnd, ...)
    {
        __try
        {
            DWORD dw;
            byte old = 0;
            BOOL bb = ReadProcessMemory(INVALID_HANDLE_VALUE, (LPCVOID)dwEnd, &old, 1, &dw);
            if (!bb)
            {
                return NULL;
            }
            byte ret = 0xc3;
            WriteProcessMemory(INVALID_HANDLE_VALUE, (LPVOID)dwEnd, &ret, 1, &dw);
            _Func fun = (_Func)(dwStart);
            HANDLE data = fun();
            WriteProcessMemory(INVALID_HANDLE_VALUE, (LPVOID)dwEnd, &old, 1, &dw);
            return data;
        }
        __except(1){return NULL;}
    }
private:
    byte m_Data[1024];
};